package com.CMUBiS.Data;
/**
 * This class contains errors that the pages could throw. We have our own errors, but I also made it so that
 * you could get any general exception to print for the user. Can be useful to throw up DB errors, although
 * ideally they should never occur
 * 
 * @author Andy (andrewtu@cmu.edu, turner.andy@gmail.com)
 * @version 0.1
 * @since 0.1
 * @date 04/05/2011
 */
public class Error extends Exception{
	private int errorNumber;
	private String name;
	private String description;
	private String full;
	
	/**
	 * Create a new error from an exception
	 * 
	 * @param description the description of the error
	 * @param e the exception that caused the error
	 * @author Andy (andrewtu@cmu.edu, turner.andy@gmail.com)
	 */
	public Error(String description, Exception e){
		super(e);
		full = description + "\n" + e.toString();
	}
	
	/**
	 * Creates a new error with the variables passed
	 * 
	 * @param errorNumber the error number that we have defined
	 * @param name the name of the error
	 * @param description the more verbose description of the error
	 * @author Andy (andrewtu@cmu.edu, turner.andy@gmail.com)
	 */
	public Error(int errorNumber, String name, String description){
		this.errorNumber = errorNumber;
		this.name = name;
		this.description = description;
		this.full = errorNumber + " " + name + " " + description;
	}
	
	/**
	 * Return the error as a String
	 * 
	 * @return String the full error message
	 * @author Andy (andrewtu@cmu.edu, turner.andy@gmail.com)
	 */
	public String toString(){
		return full;
	}
	
	/**
	 * Returns the error number of this message. Good for checking if to output pretty messages to the user
	 * 
	 * @return int the error number of this error
	 * @author Andy (andrewtu@cmu.edu, turner.andy@gmail.com)
	 */
	public int getErrorNumber(){
		return this.errorNumber;
	}
}
